package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Setmeal;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealMapper {

    List<Setmeal> selectSetMealList(Setmeal setmeal);

    @AutoFill(OperationType.INSERT)
    void insertSetmeal(Setmeal setmeal);

    Integer selectSetmealByName(String name);

    SetmealVO rowInfoById(Long id);

    @AutoFill(OperationType.UPDATE)
    void update(Setmeal setmeal);

    void deleteByIds(List<Long> ids);

    @Select("select id, category_id, name, price, status, description, image, create_time, update_time, create_user, update_user" +
            " from setmeal where id = #{id}")
    Setmeal selectSetmealById(Long id);

    Integer selectCountByIdsAndStatus(List<Long> ids);

    Integer selectSetmealByNameNotSelf(Long id, String name);

    @Select("select id, category_id, name, price, status, description, image, create_time, update_time, create_user, update_user" +
            " from setmeal where category_id = #{categoryId} and status = 1")
    List<Setmeal> selectSetmealByCategoryId(Long categoryId);

    @Select("select id, category_id, name, price, status, description, image, create_time, update_time, create_user, update_user" +
            " from setmeal where id = #{id}")
    SetmealVO selectById(Long setmealId);
}
